function resultTable=EEG_positive_file_weight_calculate(file_path)
    %file_path ='C:\Users\liwan\Desktop\MATLAB_File\periodization\periodization_code\CHBMIT_seizures_new_15_1.xlsx';
    data = readtable(file_path);
    
    % 获取唯一的文件列表 stable 保持原始顺序不变
    files = unique(data.FileName, 'stable');
    
    % 初始化计数器
    SecondsCount = 0;
    
    % 创建一个表格用于存储结果
    resultTable = table('Size', [length(files), 2], 'VariableTypes', {'string', 'double'});
    resultTable.Properties.VariableNames = {'File', 'FileWeight'};
    %记录计数器
    currentCount=1;
    % 循环处理每个文件
    for f = 1:length(files)
        currentFile = files{f};
        
        % 获取当前文件的数据
        fileData = data(strcmp(data.FileName, currentFile), :);
    
        % 初始化文件内的计数器
        fileSecondsCount = 0;
        
        % 初始化 preictal 计数器
        preictalCounter = 0;
        
        % 循环遍历当前文件的每一行数据
        for i = 1:height(fileData)
            % 获取当前行的 Type
            currentSubject = fileData.Subject{i};
            currentType = fileData.type{i};
            currentSeconds = fileData.FrameNumbers(i) / fileData.SamplingRate_Hz_(i);
            numeric_part = regexp(currentSubject, '\d+', 'match');
            subject_num = str2double(numeric_part{1});
            %% ismember(subject_num, [11,14,23]) 用于病人筛选（仅适配mit数据集） 
            %if strcmp(currentType, 'preictal')&& ismember(subject_num, [11,14,23])
            % 如果当前类型为 "preictal"
            if strcmp(currentType, 'preictal')
                % 增加一个计数器来区分不同的 "preictal" 逻辑与预处理相同 对于多端记录用编号区分
                preictalCounter = preictalCounter + 1;
                % 构建新的文件名，例如：chb01_01_positive_1.mat
                newFileName = [currentFile(1:end-4) '_positive_' num2str(preictalCounter) '.mat'];
                
                % 累加文件内计数器
                fileSecondsCount = fileSecondsCount + currentSeconds;
    
                % 将结果存储到表格中
                resultTable.File(currentCount) = newFileName;
                resultTable.FileWeight(currentCount) = fileSecondsCount;
                currentCount = currentCount + 1;
                SecondsCount = SecondsCount + fileSecondsCount;
                % 显示每个文件的结果
                disp(['File: ' newFileName ', Total "preictal" seconds: ' num2str(fileSecondsCount)]);
            end
        end
    end 
    % 移除表格中的零值行
    resultTable(resultTable.FileWeight == 0, :) = [];
    % 将预发作时间占总时间的比例存储到表格中
    resultTable.FileWeight = resultTable.FileWeight / SecondsCount;
    
    % 将结果写入 CSV 文件
    writetable(resultTable, 'positive_file_weights.csv', 'Delimiter', ',', 'QuoteStrings', true);
    
    % 显示最终结果
    disp(['Total "preictal" second across all files: ' num2str(SecondsCount)]);
end